{{#unless @isV2}}
  {{#if this.canDelete}}
    <ConfirmAction
      @buttonClasses="toolbar-link"
      @confirmTitle="Delete secret?"
      @confirmMessage="You will not be able to recover this secret data later."
      @onConfirmAction={{action "handleDelete" "v1"}}
      data-test-secret-v1-delete="true"
    >
      Delete
    </ConfirmAction>
  {{/if}}
{{else}}
  {{#if (and this.canUndeleteVersion @modelForData.deleted)}}
    <button
        type="button"
        class="toolbar-link"
        onclick={{action this.handleDelete "undelete"}}
        data-test-secret-undelete
      >
      Undelete
    </button>
  {{/if}}
  {{#if (and (not @modelForData.deleted) (not @modelForData.destroyed)) }}
    {{#if (or this.canDestroyVersion this.canDestroyAllVersions)}}
      <button
          type="button"
          class="toolbar-link"
          {{on "click" (fn (mut this.showDeleteModal false))}}
          data-test-delete-open-modal
        >
        {{if (and (not @modelForData.deleted) (not @modelForData.destroyed)) "Delete" "Destroy"}}
      </button>
      <div class="toolbar-separator"/>
    {{else}}
      {{#if (or this.canDeleteAnyVersion (and this.isLatestVersion this.canDelete))}}
        <ConfirmAction
          @buttonClasses="toolbar-link"
          @confirmTitle="Delete"
          @confirmMessage="Deleting this secret removes read access, but the underlying data will not be removed and can be undeleted later."
          @onConfirmAction={{action "handleDelete" (if canDeleteAnyVersion "delete" "delete-latest-version") }}
          data-test-secret-v2-delete="true"
        >
          Delete
        </ConfirmAction>
      {{/if}}
    {{/if}}
  {{/if}}

  <Modal
    @title="Delete Secret?"
    @onClose={{action (mut this.showDeleteModal) false}}
    @isActive={{this.showDeleteModal}}
    @type="warning"
    @showCloseButton={{true}}
  >
    <section class="modal-card-body">
      <p class="has-bottom-margin-s">There are three ways to delete or destroy the <strong>{{@model.id}}</strong> secret. Each is different, so be sure to read the below carefully.</p>
      <p class="has-bottom-margin-s"><strong>How would you like to proceed?</strong></p>
      {{#unless @modelForData.destroyed}}
        {{#unless @modelForData.deleted}}
          {{#if this.canDelete}}
            <div class="modal-radio-button" data-test-delete-modal="delete-version">
              <RadioButton
                @value="delete"
                @radioClass="radio"
                @groupValue={{this.deleteType}}
                @changed={{action (mut this.deleteType)}}
                @name="setup-deleteType"
                @radioId="delete-version"
              />
              <div class="helper-text">
                <label for="delete-version" data-test-replication-type-select="delete-version"><strong>Delete this version</strong></label>
                <p>This deletes Version {{@modelForData.version}} of the secret. It can be un-deleted later.</p>
              </div>
            </div>
          {{/if}}
        {{/unless}}
        {{#if this.canDestroyVersion}}
          <div class="modal-radio-button" data-test-delete-modal="destroy-version">
            <RadioButton
              @value="destroy"
              @radioClass="radio"
              @groupValue={{this.deleteType}}
              @changed={{action (mut this.deleteType)}}
              @name="setup-deleteType"
              @radioId="destroy-version"
            />
            <div class="helper-text">
              <label for="destroy-version" data-test-replication-type-select="destroy-version"><strong>Destroy this version</strong></label>
              <p>Version {{@modelForData.version}} is permanently destroyed and cannot be read or recovered later.</p>
            </div>
          </div>
        {{/if}}
      {{/unless}}
      {{#if this.canDestroyAllVersions}}
        <div class="modal-radio-button" data-test-delete-modal="destroy-all-versions">
          <RadioButton
            @value="destroy-all-versions"
            @radioClass="radio"
            @groupValue={{this.deleteType}}
            @changed={{action (mut this.deleteType)}}
            @name="setup-deleteType"
            @radioId="destroy-all-versions"
          />
          <div class="helper-text">
            <label for="destroy-all-versions" data-test-replication-type-select="destroy-all-versions"><strong>Destroy all versions</strong></label>
            <p>All secret versions and metadata are permanently destroyed and cannot be read or recovered later.</p>
          </div>
        </div>
      {{/if}}
    </section>
    <footer class="modal-card-foot modal-card-foot-outlined">
      <button
        type="button"
        class="button has-text-danger"
        {{on "click" (fn this.handleDelete this.deleteType (action (mut this.showDeleteModal) false))}}
        disabled={{if this.deleteType false true}}
      >
        Delete
      </button>
      <button
        type="button"
        class="button is-secondary"
        {{on "click" (action (mut this.showDeleteModal) false)}}
      >
        Cancel
      </button>
    </footer>
  </Modal>
{{/unless}}
